using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

/**
*@file       PSRole_EnterWorldSender.cs
*@brief      send message PSRole_EnterWorld
*
*@author     graywind
*@version    1.0.0.1
*@data       2012/3/26
*/

//send message PSRole_EnterWorld
public class msgPSRole_EnterWorld
{
    public const int MessageId = (int)PosServerTypes.MessageType.PSRole_EnterWorld;
    //TODO
	public int SessionId = NetLib.INVALID_SESSION;
	public objectinfo.PlayerInfoDigest MsgContent = new objectinfo.PlayerInfoDigest();
	/// <summary>
	/// Initializes a new instance of the <see cref="msgPSRole_EnterWorld"/> class.
	/// </summary>
	/// <param name='session_id'>
	/// Session_id.
	/// </param>
	/// <param name='detail'>
	/// Detail.
	/// </param>
	public msgPSRole_EnterWorld(int session_id, objectinfo.LogicObject logic_obj, objectinfo.RoleInfoDetail detail)
	{
		SessionId = session_id;
		MsgContent.ObjectInfo = logic_obj;
        MsgContent.RoleInfo.RoleCode = detail.RoleCode;
        MsgContent.RoleInfo.RoleName = detail.RoleName;
        MsgContent.RoleInfo.RoleLevel = detail.Level;
        MsgContent.RoleInfo.JobType = detail.JobType;
        MsgContent.RoleInfo.Gender = detail.Gender;
        MsgContent.RoleInfo.GraphicsId = detail.DetailData.GraphicsId;
        MsgContent.RoleInfo.WorldId = detail.WorldId;
        MsgContent.RoleInfo.Equip.AddRange(detail.DetailData.Equip);
	}
}

//handle message
public partial class gwMessagePort
{
    /// <summary>
    /// handle message
    /// </summary>
    /// <param name="msg">message wrapper of PSRole_EnterWorld</param>
    public static void ProcessMessage(msgPSRole_EnterWorld msg)
    {
        //TODO
        //Main Message:  msgPosServer
		msgPosServer mainMsg = new msgPosServer(msg.SessionId, msgPSRole_EnterWorld.MessageId, ProtoNet<objectinfo.PlayerInfoDigest>.IntoBytes(msg.MsgContent));
		gwMessagePort.ProcessMessage(mainMsg);
    }
}
